import React from 'react'
import { connect } from 'react-redux'
import { Route, Link, Redirect } from 'react-router-dom'
import App from './App'
import { logout } from './Auth.redux'
@connect(state => ({isAuth: state.auth.isAuth}), { logout })
class Dashboard extends React.Component{

    render(){
        const { match } = this.props
        return this.props.isAuth ? (
            <>
            <ul>
                <li>
                    <Link to={`${match.url}`}>一营</Link>
                </li>
                <li>
                    <Link to={`${match.url}/er`}>二营</Link>
                </li>
                <li>
                    <Link to={`${match.url}/san`}>三营</Link>
                </li>
            </ul>
            <Route path={`${match.url}`} exact component={App} />
            <Route path={`${match.url}/er`} component={() => <h1>二营</h1>} />
            <Route path={`${match.url}/san`} component={() => <h1>三营</h1>} />
            </>
        ) : (
            <Redirect to="/login"/>
        )
    }
}

export default Dashboard